package models

import (
	"github.com/astaxie/beego/orm"
)

type RoleMenu struct {
	Id     int `json:"id"`
	RoleId int `json:"role_id"`
	MenuId int `json:"menu_id"`
	BaseModels
}

func NewRoleMenu() *RoleMenu {
	return new(RoleMenu)
}

func RoleMenuTable() string {
	return AdminPrefix + "role_menu"
}

func (r *RoleMenu) FindName(RoleUrl string) (*RoleMenu, error) {
	o := orm.NewOrm()
	_ = o.Using("blog")
	role := new(RoleMenu)
	err := o.QueryTable(new(RoleMenu)).Filter("Role_url", RoleUrl).One(role)
	if err != nil {
		return role, err
	}
	return role, nil
}
